What is is-generator-fn?
The is-generator-fn package is a simple utility that allows you to check if a given function is a generator function. This can be particularly useful when working with or developing libraries that need to handle generator functions differently from regular functions, or when you want to enforce that a certain function passed to your code is a generator function for execution purposes.
Check if a function is a generator function
This feature allows you to distinguish between generator functions and regular functions. By passing a function to `isGeneratorFn`, it returns `true` if the function is a generator function and `false` otherwise. This can be useful in scenarios where specific handling or behavior is required for generator functions.
const isGeneratorFn = require('is-generator-fn');
function* generatorFunction() {}
const regularFunction = function() {};
console.log(isGeneratorFn(generatorFunction)); // true
console.log(isGeneratorFn(regularFunction)); // false